home *** CD-ROM | disk | FTP | other *** search
/ Mac-Source 1994 July / Mac-Source_July_1994.iso / C and C++ / Entertainment / MacMud / Sockets / test.c < prev    next >
Encoding:
C/C++ Source or Header  |  1989-11-06  |  960 b   |  42 lines  |  [TEXT/MPS ]

  1. #include <Events.h>
  2. #include <types.h>
  3. #include <stdio.h>
  4.  
  5. /* unixincludes */
  6. #include <sys/types.h>
  7. #include <sys/time.h>
  8. #include <sys/errno.h>
  9. #include <sys/socket.h>
  10. #include <netinet/in.h>
  11. #include <sys/file.h>
  12. #include <sys/ioctl.h>
  13. #include "tcpglue.h"
  14. #include "socket.internal.h"
  15. main()
  16. {
  17.     once();
  18.     once();
  19. }
  20. once()
  21. {
  22.     int status;
  23.     int s;
  24.     struct sockaddr_in me;
  25.     struct sockaddr_in her;
  26.     char line[100];
  27.  
  28.     s = s_socket(AF_INET,SOCK_DGRAM,0);
  29.     fprintf(stderr,"socket %d errno %d\n",s,errno);
  30.     bzero((char *)&me, sizeof(me));
  31.     me.sin_family = AF_INET;
  32.     me.sin_port = htons(25);
  33.     fprintf(stderr,"bind   %d errno %d\n",s_bind(s, (caddr_t)&me, sizeof(me), 0),errno);
  34.     her.sin_family = AF_INET;
  35.     her.sin_addr.s_addr = 0x8064660a;
  36.     her.sin_port = htons(1234);
  37.     BlockMove("\000\001rubbish\000netascii\000",line,19);
  38.     fprintf(stderr,"sendto %d errno %d\n",s_sendto(s,line,19,0,&her,sizeof(her)));
  39.     fprintf(stderr,"close  %d errno %d\n",s_close(s),errno);
  40. }
  41.     
  42.